package com.heima.controller;

import com.heima.common.PageResult;
import com.heima.common.Result;
import com.heima.pojo.VmList;
import com.heima.pojo.dto.VmPageQureyDTO;
import com.heima.pojo.dto.VmTypeDTO;
import com.heima.service.VmService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/api/vm-service/vm")
public class VmController {

    @Autowired
    private VmService vmService;
    @GetMapping("/search")
    public PageResult vmQuery(VmPageQureyDTO dto){
        log.info("设备搜索：{}",dto);
        return vmService.vmQuery(dto);
    }

    @PostMapping
    public Boolean save(@RequestBody VmList vmList){
        log.info("新增设备：{}",vmList);
        return vmService.save(vmList);
    }

    @PutMapping("/{id}/{nodeId}")
    public Boolean update(@PathVariable Long id,@PathVariable Long nodeId){
        log.info("修改售货机点位：{}，{}",id,nodeId);
        return vmService.update(id,nodeId);
    }
}
